{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YN-eakfxtLGd"
      },
      "source": [
        "# Tool Use\n",
        "\n",
        "Tool use allows customers to **connect their large language models to external tools like search engines, APIs, functions, databases**, etc.\n",
        "\n",
        "This allows the customer's model to unlock a richer set of behaviors by leveraging data stored in tools, taking actions through APIs, interacting with a vector database, querying a search engine, etc.\n",
        "\n",
        "This is particularly valuable for enterprise customers, since a lot of enterprise data lives in external sources.\n",
        "\n",
        "Tool Use consists of 4 steps:\n",
        "- Step 1: the user configures the request to the model\n",
        "- Step 2: the **model smartly decides which tool(s) to use and how**\n",
        "- Step 3: the tool calls are executed to mock database\n",
        "- Step 4: the **model generates a final answer with precise citations based on the tool results**"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "us5dkKrLCbXW",
        "outputId": "94c97f62-77fb-4492-a4e4-d9eeee4e438c"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m52.8/52.8 kB\u001b[0m \u001b[31m1.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m28.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h"
          ]
        }
      ],
      "source": [
        "# we'll use Cohere to do Tool Use\n",
        "# TODO: upgrade to \"cohere>5\"\n",
        "%pip install \"cohere<5\" --quiet"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "j0DC3iPftLGo"
      },
      "outputs": [],
      "source": [
        "import cohere, json\n",
        "API_KEY = \"...\" # fill in your Cohere API key here\n",
        "co = cohere.Client(API_KEY)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0T7yc1PltLGp"
      },
      "source": [
        "## Step 0: Create a mock database\n",
        "First, we'll define the mock data that our tools will query. This data represents sales reports and a product catalog."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "yZffY8xItLGp"
      },
      "outputs": [],
      "source": [
        "# Mock database containing daily sales reports\n",
        "sales_database = {\n",
        "    '2023-09-28': {\n",
        "        'total_sales_amount': 5000,\n",
        "        'total_units_sold': 100,\n",
        "    },\n",
        "    '2023-09-29': {\n",
        "        'total_sales_amount': 10000,\n",
        "        'total_units_sold': 250,\n",
        "    },\n",
        "    '2023-09-30': {\n",
        "        'total_sales_amount': 8000,\n",
        "        'total_units_sold': 200,\n",
        "    }\n",
        "}\n",
        "\n",
        "# Mock product catalog\n",
        "product_catalog = {\n",
        "    'Electronics': [\n",
        "        {'product_id': 'E1001', 'name': 'Smartphone', 'price': 500, 'stock_level': 20},\n",
        "        {'product_id': 'E1002', 'name': 'Laptop', 'price': 1000, 'stock_level': 15},\n",
        "        {'product_id': 'E1003', 'name': 'Tablet', 'price': 300, 'stock_level': 25},\n",
        "    ],\n",
        "    'Clothing': [\n",
        "        {'product_id': 'C1001', 'name': 'T-Shirt', 'price': 20, 'stock_level': 100},\n",
        "        {'product_id': 'C1002', 'name': 'Jeans', 'price': 50, 'stock_level': 80},\n",
        "        {'product_id': 'C1003', 'name': 'Jacket', 'price': 100, 'stock_level': 40},\n",
        "    ]\n",
        "}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6TGWYiOdtLGp"
      },
      "source": [
        "Now, we'll define the tools that simulate querying this database.  \n",
        "You could for example use the API of an enterprise sales platform.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "YuIH4us8tLGp"
      },
      "outputs": [],
      "source": [
        "def query_daily_sales_report(day: str) -> dict:\n",
        "    \"\"\"\n",
        "    Function to retrieve the sales report for the given day\n",
        "    \"\"\"\n",
        "    report = sales_database.get(day, {})\n",
        "    if report:\n",
        "        return {\n",
        "            'date': day,\n",
        "            'summary': f\"Total Sales Amount: {report['total_sales_amount']}, Total Units Sold: {report['total_units_sold']}\"\n",
        "        }\n",
        "    else:\n",
        "        return {'date': day, 'summary': 'No sales data available for this day.'}\n",
        "\n",
        "\n",
        "def query_product_catalog(category: str) -> dict:\n",
        "    \"\"\"\n",
        "    Function to retrieve products for the given category\n",
        "    \"\"\"\n",
        "    products = product_catalog.get(category, [])\n",
        "    return {\n",
        "        'category': category,\n",
        "        'products': products\n",
        "    }\n",
        "\n",
        "\n",
        "functions_map = {\n",
        "    \"query_daily_sales_report\": query_daily_sales_report,\n",
        "    \"query_product_catalog\": query_product_catalog\n",
        "}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "HZRhTu4ftLGp"
      },
      "source": [
        "## Step 1 - the user configures the request to the model\n",
        "\n",
        "The developer provides a few things to the model:\n",
        "- A preamble containing instructions about the task and the desired style for the output.\n",
        "- The user request.\n",
        "- A list of tools to the model.\n",
        "- (Optionally) a chat history for the model to work with.\n",
        "\n",
        "\n",
        "You can specify one or many tools to the model. Every tool needs to be described with a JSON schema, indicating the tool name, description, and parameters (code snippets below).\n",
        "\n",
        "In our example, we provide two tools to the model: `daily_sales_report` and `product_catalog`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "aIk-of_OtLGp"
      },
      "outputs": [],
      "source": [
        "# tool descriptions that the model has access to\n",
        "# note: Cohere always adds a \"directly_answer\" tool under the hood, so that the model can decide to not leverage any tool, if they're not needed.\n",
        "tools = [\n",
        "    {\n",
        "        \"name\": \"query_daily_sales_report\",\n",
        "        \"description\": \"Connects to a database to retrieve overall sales volumes and sales information for a given day.\",\n",
        "        \"parameter_definitions\": {\n",
        "            \"day\": {\n",
        "                \"description\": \"Retrieves sales data for this day, formatted as YYYY-MM-DD.\",\n",
        "                \"type\": \"str\",\n",
        "                \"required\": True\n",
        "            }\n",
        "        }\n",
        "    },\n",
        "    {\n",
        "        \"name\": \"query_product_catalog\",\n",
        "        \"description\": \"Connects to a a product catalog with information about all the products being sold, including categories, prices, and stock levels.\",\n",
        "        \"parameter_definitions\": {\n",
        "            \"category\": {\n",
        "                \"description\": \"Retrieves product information data for all products in this category.\",\n",
        "                \"type\": \"str\",\n",
        "                \"required\": True\n",
        "            }\n",
        "        }\n",
        "    }\n",
        "]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "k2AHJRnztLGp"
      },
      "source": [
        "Now let's define the user request.  \n",
        "\n",
        "In our example we'll use: \"Can you provide a sales summary for 29th September 2023, and also give me the details of all products in the 'Electronics' category that were sold that day, including their prices and stock levels?\"\n",
        "\n",
        "Only a langage model with Tool Use can answer this request: it requires looking up information in the right external tools (step 2), and then providing a final answer based on the tool results (step 4)."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "JuDgJ7fjtLGq"
      },
      "outputs": [],
      "source": [
        "# preamble containing instructions about the task and the desired style for the output.\n",
        "preamble = \"\"\"\n",
        "## Task & Context\n",
        "You help people answer their questions and other requests interactively. You will be asked a very wide array of requests on all kinds of topics. You will be equipped with a wide range of search engines or similar tools to help you, which you use to research your answer. You should focus on serving the user's needs as best you can, which will be wide-ranging.\n",
        "\n",
        "## Style Guide\n",
        "Unless the user asks for a different style of answer, you should answer in full sentences, using proper grammar and spelling.\n",
        "\"\"\"\n",
        "\n",
        "# user request\n",
        "message = \"Can you provide a sales summary for 29th September 2023, and also give me some details about the products in the 'Electronics' category, for example their prices and stock levels?\""
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1NhW-G_JtLGq"
      },
      "source": [
        "## Step 2 – the model smartly decides which tool(s) to use and how\n",
        "The model intelligently selects the right tool(s) to call -- and the right parameters for each tool call -- based on the content of the user message."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "o79_n99GtLGq",
        "outputId": "81789d00-01b9-4c17-d1b0-1668d75a2b86"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "The model recommends doing the following tool calls:\n",
            "cohere.ToolCall {\n",
            "\tname: query_daily_sales_report\n",
            "\tparameters: {'day': '2023-09-29'}\n",
            "\tgeneration_id: eaf955e3-623d-4796-bf51-23b07c66ed2c\n",
            "}\n",
            "cohere.ToolCall {\n",
            "\tname: query_product_catalog\n",
            "\tparameters: {'category': 'Electronics'}\n",
            "\tgeneration_id: eaf955e3-623d-4796-bf51-23b07c66ed2c\n",
            "}\n"
          ]
        }
      ],
      "source": [
        "response = co.chat(\n",
        "    message=message,\n",
        "    tools=tools,\n",
        "    preamble=preamble,\n",
        "    model=\"command-r\"\n",
        ")\n",
        "\n",
        "# Note that the Cohere Chat API also exposes:\n",
        "# - stream (for streaming mode)\n",
        "# - chat_history\n",
        "# - among other parameters\n",
        "# See https://docs.cohere.com/reference/chat for details.\n",
        "\n",
        "print(\"The model recommends doing the following tool calls:\")\n",
        "print(\"\\n\".join(str(tool_call) for tool_call in response.tool_calls))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "md_9QPcxtLGq"
      },
      "source": [
        "## Step 3 – the tool calls are executed\n",
        "\n",
        "You can then execute the appropriate calls, using the tool calls and tool parameters generated by the model.  \n",
        "These tool calls return tool results that will be fed to the model in Step 4."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "1LuDCRpFtLGr",
        "outputId": "42ead35e-225a-4b9a-c954-b526f2865350"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "= running tool query_daily_sales_report, with parameters: {'day': '2023-09-29'}\n",
            "== tool results: [{'date': '2023-09-29', 'summary': 'Total Sales Amount: 10000, Total Units Sold: 250'}]\n",
            "= running tool query_product_catalog, with parameters: {'category': 'Electronics'}\n",
            "== tool results: [{'category': 'Electronics', 'products': [{'product_id': 'E1001', 'name': 'Smartphone', 'price': 500, 'stock_level': 20}, {'product_id': 'E1002', 'name': 'Laptop', 'price': 1000, 'stock_level': 15}, {'product_id': 'E1003', 'name': 'Tablet', 'price': 300, 'stock_level': 25}]}]\n",
            "Tool results that will be fed back to the model in step 4:\n",
            "[\n",
            "    {\n",
            "        \"call\": {\n",
            "            \"name\": \"query_daily_sales_report\",\n",
            "            \"parameters\": {\n",
            "                \"day\": \"2023-09-29\"\n",
            "            },\n",
            "            \"generation_id\": \"eaf955e3-623d-4796-bf51-23b07c66ed2c\"\n",
            "        },\n",
            "        \"outputs\": [\n",
            "            {\n",
            "                \"date\": \"2023-09-29\",\n",
            "                \"summary\": \"Total Sales Amount: 10000, Total Units Sold: 250\"\n",
            "            }\n",
            "        ]\n",
            "    },\n",
            "    {\n",
            "        \"call\": {\n",
            "            \"name\": \"query_product_catalog\",\n",
            "            \"parameters\": {\n",
            "                \"category\": \"Electronics\"\n",
            "            },\n",
            "            \"generation_id\": \"eaf955e3-623d-4796-bf51-23b07c66ed2c\"\n",
            "        },\n",
            "        \"outputs\": [\n",
            "            {\n",
            "                \"category\": \"Electronics\",\n",
            "                \"products\": [\n",
            "                    {\n",
            "                        \"product_id\": \"E1001\",\n",
            "                        \"name\": \"Smartphone\",\n",
            "                        \"price\": 500,\n",
            "                        \"stock_level\": 20\n",
            "                    },\n",
            "                    {\n",
            "                        \"product_id\": \"E1002\",\n",
            "                        \"name\": \"Laptop\",\n",
            "                        \"price\": 1000,\n",
            "                        \"stock_level\": 15\n",
            "                    },\n",
            "                    {\n",
            "                        \"product_id\": \"E1003\",\n",
            "                        \"name\": \"Tablet\",\n",
            "                        \"price\": 300,\n",
            "                        \"stock_level\": 25\n",
            "                    }\n",
            "                ]\n",
            "            }\n",
            "        ]\n",
            "    }\n",
            "]\n"
          ]
        }
      ],
      "source": [
        "tool_results = []\n",
        "# Iterate over the tool calls generated by the model\n",
        "for tool_call in response.tool_calls:\n",
        "    # here is where you would call the tool recommended by the model, using the parameters recommended by the model\n",
        "    print(f\"= running tool {tool_call.name}, with parameters: {tool_call.parameters}\")\n",
        "    output = functions_map[tool_call.name](**tool_call.parameters)\n",
        "    # store the output in a list\n",
        "    outputs = [output]\n",
        "    print(f\"== tool results: {outputs}\")\n",
        "    # store your tool results in this format\n",
        "    tool_results.append({\n",
        "        \"call\": tool_call,\n",
        "        \"outputs\": outputs\n",
        "    })\n",
        "\n",
        "print(\"Tool results that will be fed back to the model in step 4:\")\n",
        "print(json.dumps(tool_results, indent=4))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8cKlLk18tLGr"
      },
      "source": [
        "## Step 4 - the model generates a final answer based on the tool results\n",
        "Finally, the developer calls the Cohere model, providing the tools results, in order to generate the model's final answer.  \n",
        "\n",
        "Bonus: At Cohere, all Tool Use calls come with... **precise citations**! 🎉\n",
        "The model cites which tool results were used to generate the final answer.  \n",
        "These citations make it easy to check where the model’s generated response claims are coming from.  \n",
        "They help users gain visibility into the model reasoning, and sanity check the final model generation.  \n",
        "These citations are optional — you can decide to ignore them.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "MKnjXVfXtLGr"
      },
      "outputs": [],
      "source": [
        "response = co.chat(\n",
        "    message=message,\n",
        "    tools=tools,\n",
        "    tool_results=tool_results,\n",
        "    preamble=preamble,\n",
        "    model=\"command-r\",\n",
        "    temperature=0.3\n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "jlxKTsaztLGr",
        "outputId": "b2cd8667-bca9-4928-c423-61930b4b49fa"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Final answer:\n",
            "On the 29th of September 2023, there were 10,000 sales with 250 units sold. \n",
            "\n",
            "The Electronics category contains three products. There are details below:\n",
            "\n",
            "| Product Name | Price | Stock Level |\n",
            "| ------------ | ----- | ----------- |\n",
            "| Smartphone | 500 | 20 |\n",
            "| Laptop | 1000 | 15 |\n",
            "| Tablet | 300 | 25 | \n",
            "\n",
            "The total stock level for Electronics items is 50.\n"
          ]
        }
      ],
      "source": [
        "print(\"Final answer:\")\n",
        "print(response.text)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "niMkAr2PN9j4"
      },
      "source": [
        "## Bonus: Citations come for free with Cohere! 🎉\n",
        "\n",
        "At Cohere, model generations come with... precise citations! 🎉\n",
        "The model cites which groups of words, in the tool results, were used to generate the final answer.  \n",
        "These citations make it easy to check where the model’s generated response claims are coming from.  \n",
        "They help users gain visibility into the model reasoning, and sanity check the final model generation.  \n",
        "These citations are optional — you can decide to ignore them."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "9wuoCUBwtLGr",
        "outputId": "da3c0dc5-6b87-42ea-d64b-e7e85c40273e"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Citations that support the final answer:\n",
            "{'start': 7, 'end': 29, 'text': '29th of September 2023', 'document_ids': ['query_daily_sales_report:0:0']}\n",
            "{'start': 42, 'end': 75, 'text': '10,000 sales with 250 units sold.', 'document_ids': ['query_daily_sales_report:0:0']}\n",
            "{'start': 112, 'end': 127, 'text': 'three products.', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 234, 'end': 244, 'text': 'Smartphone', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 247, 'end': 250, 'text': '500', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 253, 'end': 255, 'text': '20', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 260, 'end': 266, 'text': 'Laptop', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 269, 'end': 273, 'text': '1000', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 276, 'end': 278, 'text': '15', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 283, 'end': 289, 'text': 'Tablet', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 292, 'end': 295, 'text': '300', 'document_ids': ['query_product_catalog:1:0']}\n",
            "{'start': 298, 'end': 300, 'text': '25', 'document_ids': ['query_product_catalog:1:0']}\n"
          ]
        }
      ],
      "source": [
        "print(\"Citations that support the final answer:\")\n",
        "for cite in response.citations:\n",
        "  print(cite)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "7td1J80DOKTM",
        "outputId": "e6e4fa7d-67eb-42ca-e736-9a45a47a6c1d"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "On the **29th of September 2023**[1], there were **10,000 sales with 250 units sold.**[1] \n",
            "\n",
            "The Electronics category contains **three products.**[2] There are details below:\n",
            "\n",
            "| Product Name | Price | Stock Level |\n",
            "| ------------ | ----- | ----------- |\n",
            "| **Smartphone**[2] | **500**[2] | **20**[2] |\n",
            "| **Laptop**[2] | **1000**[2] | **15**[2] |\n",
            "| **Tablet**[2] | **300**[2] | **25**[2] | \n",
            "\n",
            "The total stock level for Electronics items is 50.\n",
            "\n",
            "[1] source: [{'date': '2023-09-29', 'summary': 'Total Sales Amount: 10000, Total Units Sold: 250'}] \n",
            "    based on tool call: {'name': 'query_daily_sales_report', 'parameters': {'day': '2023-09-29'}, 'generation_id': 'eaf955e3-623d-4796-bf51-23b07c66ed2c'}\n",
            "[2] source: [{'category': 'Electronics', 'products': [{'product_id': 'E1001', 'name': 'Smartphone', 'price': 500, 'stock_level': 20}, {'product_id': 'E1002', 'name': 'Laptop', 'price': 1000, 'stock_level': 15}, {'product_id': 'E1003', 'name': 'Tablet', 'price': 300, 'stock_level': 25}]}] \n",
            "    based on tool call: {'name': 'query_product_catalog', 'parameters': {'category': 'Electronics'}, 'generation_id': 'eaf955e3-623d-4796-bf51-23b07c66ed2c'}\n"
          ]
        }
      ],
      "source": [
        "def insert_citations_in_order(text, citations):\n",
        "    \"\"\"\n",
        "    A helper function to pretty print citations.\n",
        "    \"\"\"\n",
        "    offset = 0\n",
        "    document_id_to_number = {}\n",
        "    citation_number = 0\n",
        "    modified_citations = []\n",
        "\n",
        "    # Process citations, assigning numbers based on unique document_ids\n",
        "    for citation in citations:\n",
        "        citation_numbers = []\n",
        "        for document_id in sorted(citation[\"document_ids\"]):\n",
        "            if document_id not in document_id_to_number:\n",
        "                citation_number += 1  # Increment for a new document_id\n",
        "                document_id_to_number[document_id] = citation_number\n",
        "            citation_numbers.append(document_id_to_number[document_id])\n",
        "\n",
        "        # Adjust start/end with offset\n",
        "        start, end = citation['start'] + offset, citation['end'] + offset\n",
        "        placeholder = ''.join([f'[{number}]' for number in citation_numbers])\n",
        "        # Bold the cited text and append the placeholder\n",
        "        modification = f'**{text[start:end]}**{placeholder}'\n",
        "        # Replace the cited text with its bolded version + placeholder\n",
        "        text = text[:start] + modification + text[end:]\n",
        "        # Update the offset for subsequent replacements\n",
        "        offset += len(modification) - (end - start)\n",
        "\n",
        "    # Prepare citations for listing at the bottom, ensuring unique document_ids are listed once\n",
        "    unique_citations = {number: doc_id for doc_id, number in document_id_to_number.items()}\n",
        "    citation_list = '\\n'.join([f'[{doc_id}] source: {tool_results[doc_id - 1][\"outputs\"]} \\n    based on tool call: {dict(tool_results[doc_id - 1][\"call\"])}' for doc_id, number in sorted(unique_citations.items(), key=lambda item: item[1])])\n",
        "    text_with_citations = f'{text}\\n\\n{citation_list}'\n",
        "\n",
        "    return text_with_citations\n",
        "\n",
        "\n",
        "print(insert_citations_in_order(response.text, response.citations))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "RwH2O3FptLGr"
      },
      "source": [
        "Yiha. You've used Cohere for Tool Use.  Tool use opens up a wide range of new use cases. Here are a few examples:\n",
        "\n",
        "- **Function calling**: It's now possible to ask the model to output a JSON object with specific function parameters.\n",
        "For instance, this allows your chatbot to interact with your CRM to change the status of a deal, or to engage with a Python interpreter to conduct data science analyses.\n",
        "\n",
        "- **Query transformation**: You can transform a user message into a search query for a vector database or any search engine.\n",
        "For instance, this enables your work assistant to automatically retrieve the appropriate data from your company's documentation by creating the right query for your vector database.\n",
        "\n",
        "- **Advanced searches**: You can transform a user message into one-or-many queries, to do multiple subtasks based on the content of the message.\n",
        "For instance, this allows your chatbot to search across different databases and platforms to retrieve relevant information or to conduct comparative analysis.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "FXOSzfqRCLBH"
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "hackathon_demo",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.11.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
